$(function(){
    obj.init();
});

window.obj = new function(){
    'use strict';
    return {
        form: null,
        dom: {
            save: null
        },
        params: {
            appId: null
        },
        init: function () {
            this.params.appId = xhTool.getQuery('appId');

            this.dom.save = window.top.xhTop.getModalConfirmDom();

            this.form = new xhForm($('#xh_form'));
            this.form.parse().bindRequired(this.dom.save);

            this.listener();
            this.funObj().initData();
        },
        listener: function () {
            var $this = this;
            //保存
            $this.dom.save.click(function(){
                $this.funObj().modifyAppBase();
            });
        },
        funObj: function(){
            var $this = this;
            return {
                initData: function () {
                    xhExtra.ajaxRequest('appserver/getApplicationInfo/' + $this.params.appId, {}, {check: true, success: false}, function (appInfo) {
                        $this.form.fill(appInfo);
                    });
                },
                modifyAppBase: function () {
                    $this.form.submit(baseUrl + 'Appserver/modifyAppBase', {appId: $this.params.appId}, function(data){
                        xhExtra.setBtnNormal($this.dom.save);
                        if(xhExtra.checkError(data)) return false;
                        window.top.xhTop.getActiveFrame().obj.dataGrid.reload();
                        window.top.xhTop.showSuccess(data.msg);
                        window.top.xhTop.closeModal();
                    }, {check: false});
                }
            }
        }
    }
};